home *** CD-ROM | disk | FTP | other *** search
- Path: atglab.bls.com!Alun.Champion
- From: Alun.Champion@bridge.bst.bls.com (Alun Champion)
- Newsgroups: comp.unix.osf.osf1,comp.lang.c
- Subject: Re: printf-problem
- Date: 17 Jan 1996 21:18:24 GMT
- Organization: Computer People Inc.
- Distribution: world
- Message-ID: <ALUN.CHAMPION.96Jan17161824@g7240065.bridge.bst.bls.com>
- References: <4dj4g6$t9f@sunsystem5.informatik.tu-muenchen.de>
- NNTP-Posting-Host: bstfirewall.bst.bls.com
- In-reply-to: wist@lam.mw.tu-muenchen.de's message of 17 Jan 1996 15:27:02 GMT
-
- In article <4dj4g6$t9f@sunsystem5.informatik.tu-muenchen.de> wist@lam.mw.tu-muenchen.de (Henrik Wist) writes:
-
- : long int zahl; /* which is e.g. 10000500001 */
- : printf("%d\n",zahl); /* gives 1410565409, which is definitly wrong */
-
- Though the FAQ goes into a lot of detail about printf and scanf, but it
- sort of misses this one. The closes it gets is in the answer to
- "How can I convert numbers to strings (the opposite of atoi)?"
- In the answer it says :-
- You can obviously use sprintf() to convert long or floating-
- point numbers to strings as well (using %ld or %f).
-
- I suppose the answer is there ;')
-
- Anyway the answer is %d is the printf specifier for ints not longs
- %ld is the printf specifier for longs. Man pages and/or almost any book
- on 'C' could have told you this.
-
- Regards
-
- -A.
- --
- | A.Champion |
-